package com.itboye.sunsun;

import java.util.ArrayList;
import java.util.List;

import com.itboye.sunsun.Application.App;
import com.itboye.sunsun.adapter.ShopAdapter;
import com.itboye.sunsun.beans.GoodBean;
import com.itboye.sunsun.custome.CarouselView;
import com.itboye.sunsun.custome.XListView;
import com.itboye.sunsun.support.BaseFragment;
import com.itboye.sunsun.test.ImageUrls;
import com.itboye.sunsun.utils.DensityUtil;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.ListView;
import android.widget.TableLayout.LayoutParams;
 
public class HomeFragment extends BaseFragment{
	
	private View homeView;
	
//	private Context App.ctx;
	
	private XListView listView;
	 
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {	
		homeView = inflater.inflate(R.layout.fragment_home, container, false);

		smartInject(homeView);
		
		return homeView;
	}
	
	
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);
		CarouselView carouselView=new CarouselView(App.ctx);
		AbsListView.LayoutParams params=new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,DensityUtil.dip2px(200));
		
		carouselView.setLayoutParams(params);
		listView.addHeaderView(carouselView);
		listView.addHeaderView(LayoutInflater.from(App.ctx).inflate(R.layout.item_goods_header_animal, null));
		
		listView.addHeaderView(LayoutInflater.from(App.ctx).inflate(R.layout.item_goods_header_oeder, null));
		
		List<ImageView>bmps=new ArrayList<>();
		for (int i = 0; i < 5; i++) {
			ImageView imageView=new ImageView(App.ctx);
			imageView.setImageResource(R.drawable.ic_launcher);
			 imageView.setBackgroundColor(Color.YELLOW);
			 imageView.setScaleType(ScaleType.CENTER_CROP);
			bmps.add( imageView);
		}
		
		carouselView.setImageBitmaps(bmps);
		carouselView.setBackgroundColor(Color.BLUE);
		
		List<GoodBean>list=new ArrayList<>();
		for (int i = 0; i <150; i++) {
			GoodBean bean=new GoodBean();
			bean.setUrl(ImageUrls.getImages().get(i));
			list.add(bean);
		}
		listView.setAdapter(new ShopAdapter(list));
		 
		
	}

}
